package lab2.homework4;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class FileCopy {
	public static void main(String[] args) throws IOException {
		
		String srcPath = "source.txt";
		String destPath = "result.txt";
		
		File src = new File(srcPath);
		File dest = new File(destPath);
		
		InputStream input = null;
		OutputStream output = null;
		
		try {
			input = new FileInputStream(src);
			output = new FileOutputStream(dest);
			
			byte[] by = new byte[1024];
			int len = -1;
			while((len = input.read(by)) != -1){
				output.write(by);
			}
			output.flush();
//			System.out.println("OK");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			input.close();
			output.close();
		}
	}
}
